#include "collision_primitive.h"

using namespace TorPhysix;


void CollisionPrimitive::calculateInternals()
{
	transform = body->getTransform() * offset;
}

// TODO. increase radius
void TorPhysix::CollisionSphere::scale( Vec3f scaleDelta )
{
	radius += ( scaleDelta.x() + scaleDelta.y() + scaleDelta.z() ) / 3.0f;
	if( radius < (real)0.5 ) radius = (real)0.5;
}

void TorPhysix::CollisionBox::scale( Vec3f scaleDelta )
{
	halfSize += scaleDelta;
	// Is smaller than unit box? Dont't allow geometry to become inverted
	if( halfSize.x() < 0.5f ) halfSize.x() = 0.5f;
	if( halfSize.y() < 0.5f ) halfSize.y() = 0.5f;
	if( halfSize.z() < 0.5f ) halfSize.z() = 0.5f;
	body->calculateDerivedData();
}
